package com.yq.cp.controller.file;


import com.yq.cp.entity.common.ApiResult;
import com.yq.cp.utils.FileUploadUtli;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 文件上传
 */
@RestController
@RequestMapping
public class FileUploadController{

    @Resource
    private FileUploadUtli fileUploadUtli;

    /**
     * 单文件上传
     *
     * @param file 文件
     */
    @ResponseBody
    @PostMapping("upload/file")
    public ApiResult uploadFile(@RequestParam("file") MultipartFile file) {
        return ApiResult.ok().data(fileUploadUtli.uploadFile(file));
    }
    @ResponseBody
    @PostMapping("upload/file/aly")
    public ApiResult uploadFileAly(@RequestParam("file") MultipartFile file) {
        return ApiResult.ok().data(fileUploadUtli.aly(file));
    }
    /**
     * 多文件上传
     *
     */
    @ResponseBody
    @PostMapping("upload/files")
    public ApiResult uploadFiles(@RequestParam("files") MultipartFile[] files) {
        return ApiResult.ok().data(fileUploadUtli.uploadFileList(files));
    }

}
